﻿using System;

using SBPweb.MediaCenter.Common.Modularity;

namespace SBPweb.MediaCenter.Common.Communication
{
    public class RequestObjectMessage<T> : MessageBase, IRequestMessage<T>
    {

        #region Private fields

        private T pResponse;

        #endregion

        #region Constructor logic

        public RequestObjectMessage(IModule sender, string text)
            : base(sender, text)
        {
        }

        #endregion

        #region Property accessors

        public T Response
        {
            get
            {
                return pResponse;
            }
            set
            {
                pResponse = value;
                if (Respond != null)
                {
                    Respond(pSender, new RequestMessageEventArgs<T>(this));
                }
            }
        }

        #endregion

        #region Event handlers

        public event EventHandler<RequestMessageEventArgs<T>> Respond;

        #endregion
    }
}